package com.drg.center.controller;

import com.drg.center.entity.param.CaseMonitorPageDTO;
import com.drg.center.entity.param.CaseOutMonitorPageDTO;
import com.drg.center.entity.result.*;
import com.drg.center.service.CaseMonitorService;
import com.guaike.core.entity.result.PageEntity;
import com.guaike.core.entity.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


@Slf4j
@RestController
@RequestMapping("/caseMonitor")
@Api(tags = "病例监测接口组")
@AllArgsConstructor
public class CaseMonitorController {

    private final CaseMonitorService caseMonitorService;

    @GetMapping("/inHospitalStat")
    @ApiOperation(value = "在院病例监测统计")
    public Result<CaseMonitorStatVO> inHospitalStat(@Valid CaseMonitorPageDTO param) {
        return caseMonitorService.inHospitalStat(param);
    }

    @GetMapping("/inHospitalPage")
    @ApiOperation(value = "在院病例监测列表")
    public Result<PageEntity<CaseMonitorPageVO>> inHospitalPage(@Valid CaseMonitorPageDTO param) {
        return caseMonitorService.inHospitalPage(param);
    }

    @GetMapping("/outHospitalStat")
    @ApiOperation(value = "出院病例监测统计")
    public Result<CaseMonitorOutStatVO> outHospitalStat(@Valid CaseOutMonitorPageDTO param) {
        return caseMonitorService.outHospitalStat(param);
    }

    @GetMapping("/outHospitalPage")
    @ApiOperation(value = "出院病例监测列表")
    public Result<PageEntity<CaseOutMonitorPageVO>> outHospitalPage(@Valid CaseOutMonitorPageDTO param) {
        return caseMonitorService.outHospitalPage(param);
    }

    @GetMapping("/caseDetail")
    @ApiOperation(value = "病例监测明细")
    public Result<CaseMonitorVO> caseDetail(@ApiParam("类型（1：在院，2：离院）") @RequestParam("type") Integer type, @ApiParam("病案号") @RequestParam("caseCode") String caseCode) {
        return caseMonitorService.caseDetail(type, caseCode);
    }

    @GetMapping("/searchDRG")
    @ApiOperation(value = "搜索drg分组情况")
    public Result<List<DrgVO>> searchDRG(@ApiParam("搜索字段，编码/名称") @RequestParam("search") String search) {
        return caseMonitorService.searchDRG(search);
    }
}
